<template>
  <div class="tabControl">
    <div
      class="tabControlItem"
      v-for="(item,index) in titles"
      :key="index"
      :class="{tabActive:currentIndex==index}"
			@click="itemClick(index)"
    >
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      currentIndex: 0
    };
	},
	methods:{
		itemClick(index){
			this.currentIndex = index
			this.$emit("getIndex",index)
		}
	}
};
</script>

<style>
.tabControl {
  display: flex;
  height: 44px;
  line-height: 44px;
  text-align: center;
  font-size: 15px;
  background-color: pink;
}
.tabControlItem {
  flex: 1;
}
.tabControlItem span {
  padding: 3px;
}
.tabActive {
  color: var(--color-high-text);
}
.tabActive span {
  border-bottom: 1px solid var(--color-high-text);
}
</style>
